#include "CMultiCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"

extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CMultiCommand::~CMultiCommand ()
{
	for (u32 i = 0; i < m_commands.size(); ++i)
		m_commands[i]->drop();
}

void CMultiCommand::addCommand (IDoUndoCommand* command)
{
	command->grab();
	m_commands.push_back(command);
}

void CMultiCommand::redo ()
{
	for (u32 i = 0; i < m_commands.size(); ++i)
	{
		m_commands[i]->redo();
	}
}

void CMultiCommand::undo ()
{
	for (int i = m_commands.size() - 1; i >= 0; --i)
	{
		m_commands[i]->undo();
	}
}
